/**
 * @file modes.cpp
 *
 * @date 22/12/2011
 * @author Tales 
 *
 */

#include "modes.hpp"
#include "ConsoleModeBase.hpp"
#include "InfoMode.hpp"
#include "NewMode.hpp"
#include "../common/Error.hpp"
#include "ChangeColorMode.hpp"
#include "ToolMode.hpp"
#include "SelectLayerMode.hpp"
#include "LayerManagerMode.hpp"
#include "PersistenceMode.hpp"

#define NUM_MODES 7

namespace yep
{

namespace modes
{
static ConsoleModeBase *modes[NUM_MODES];
static bool initModes = false;
size_t getCount()
{
	return NUM_MODES;
}

ConsoleModeBase & get(size_t index)
{
	YEP_ASSERT(index < NUM_MODES);
	if (!initModes)
	{
		modes[0] = new InfoMode;
		modes[1] = new NewMode;
		modes[2] = new ChangeColorMode;
		modes[3] = new ToolMode;
		modes[4] = new SelectLayerMode;
		modes[5] = new LayerManagerMode;
		modes[6] = new PersistenceMode;
		initModes = true;
	}
	return *modes[index];
}

void chooseMode(size_t index)
{
	ConsoleModeBase &newMode = get(index);
	Mode::setCurrentMode(newMode);
	newMode.setup();
}

} // namespace modes

}

// namespace yep

